package com.chaoyue.media.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import com.chaoyue.media.beans.po.MediaProcess;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author whr
 */
public interface MediaProcessMapper extends BaseMapper<MediaProcess> {
    @Select("select * from media_process t1 where t1.id % #{shardTotal}= #{shardIndex} and (t1.status='1' or t1.status='3') and t1.fail_count <3 limit #{total}")
    List<MediaProcess> selectListByShardIndex(@Param("shardTotal") int shardTotal, @Param("shardIndex") int shardIndex, @Param("total") int total);

    @Update("update media_process m set m.status='4' where (m.status='1' or m.status='3') and m.fail_count<3 and m.id=#{id}")
    int startTask(@Param("id") long id);

}
